<%@ page import="java.util.List" %>
<%@ page import="com.project.purchase.entity.Person" %>
<%@ page import="com.project.purchase.vo.PersonWithDept" %>
<%@ page import="com.github.pagehelper.PageInfo" %>
<%@ page import="com.project.purchase.entity.User" %><%--
  Created by IntelliJ IDEA.
  User: VX5
  Date: 2019/6/21
  Time: 15:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script>
        var i = 0;
        function x() {
            i = i + 1;
            return i;
        }
    </script>

    <style>
        .modal-dialog{
            pointer-events: auto;
        }
        .navbar{
            min-height: 20px;
        }
        .add{
            margin-outside: 5px;
            margin-top: 8px;
            min-height: 20px;
            min-width: 10%;
        }
        .back{
            margin-outside: 5px;
            margin-top: 13px;
            min-height: 10px;
            min-width: 15%;
            text-align: center;
            margin-bottom: 5px;
        }
        .page{
            margin-outside: 0px;
            margin-top: 3px;
            min-height: 1%;
            min-width: 15%;
        }
        .pagination{
            margin-bottom: 0px;
            text-align: right;
        }
        .navbar-brand2{
            min-height: 10px;
        }
        .bg {
                background: url("E:/purchase/src/main/webapp/timg.jpg");
                background-position: center 0;
                background-repeat: no-repeat;
                background-attachment: fixed;
                 background-size: cover;
                -webkit-background-size: cover;
                -o-background-size: cover;
                -moz-background-size: cover;
                -ms-background-size: cover;
        }
    </style>
</head>
<body >
<%
    User user = (User) request.getSession().getAttribute("user");
%>
<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid" style="background-color: #0DA3E2">
        <div class="navbar-header" style="font-family: 华文新魏;font-size: 25px">
            国有资产采购管理系统
        </div>
        <%
            if(user.getParam().equals("user")){
        %>
        <div class="nav navbar-nav" style="float: right;font-family: 华文新魏;font-size: 20px">
            欢迎 员工用户 <%=user.getLoginname()%>!  <a href="/login/back">退出</a>
        </div>
        <%
        }else if (user.getParam().equals("producer")){
        %>
        <div class="nav navbar-nav" style="float: right;font-family: 华文新魏;font-size: 20px">
            欢迎 商户用户 <%=user.getLoginname()%>!  <a href="/login/back">退出</a>
        </div>
        <%
        }else {
        %>
        <div class="nav navbar-nav" style="float: right;font-family: 华文新魏;font-size: 20px">
            欢迎 管理员 <%=user.getLoginname()%>!  <a href="/login/back">退出</a>
        </div>
        <%
            }
        %>
    </div>
</nav>


<div class="container bg">
    <nav class="navbar navbar-default" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">国有资产采购管理系统</a>
            </div>
            <div>

                <ul class="nav navbar-nav">
                    <li><a href="/home/get">主   页</a></li>
                    <li><a href="/person/get">用户管理</a></li>
                    <li><a href="/indent/get">订单管理</a></li>
                    <li><a href="/producer/get">商户管理</a></li>
                    <li><a href="/goods/get">已订货物</a> </li>
                </ul>
            </div>
        </div>
    </nav>
    <nav class="navbar navbar-default" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <p class="navbar-text">用户管理</p>
            </div>

            <form class="navbar-form navbar-right" role="search" action="/person/search" method="post">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="Search" name="search">
                </div>
                <button type="submit" class="btn btn-default">查找</button>
            </form>
            <%
                if (user.getParam().equals("admin")){
            %>
            <div class="pull-right add">
                <a href="#" class="btn btn-primary " style="min-width: 100%" data-toggle="modal" data-target="#myModal">添加</a>
                <!-- 模态框（Modal） -->
                <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                    &times;
                                </button>
                                <h4 class="modal-title" id="myModalLabel">
                                    添加用户信息
                                </h4>
                            </div>
                            <div style="padding: 100px 100px 10px;">
                                <form class="bs-example bs-example-form" role="form" action="/person/add" method="post">
                                    <div class="input-group input-group-lg">
                                        <span class="input-group-addon">姓       名</span>
                                        <input type="text" class="form-control" placeholder="Twitterhandle" name="name">
                                    </div>
                                    <br>
                                    <div class="input-group input-group-lg">
                                        <span class="input-group-addon">电       话</span>
                                        <input type="text" class="form-control" placeholder="Twitterhandle" name="tel">
                                    </div>
                                    <br>
                                    <div class="input-group input-group-lg">
                                        <span class="input-group-addon">部       门</span>
                                        <input type="text" class="form-control" placeholder="Twitterhandle" name="department">
                                    </div>
                                    <br>
                                    <div class="input-group input-group-lg">
                                        <span class="input-group-addon">用户名</span>
                                        <input type="text" class="form-control" placeholder="Twitterhandle" name="username">
                                    </div>
                                    <br>
                                    <div class="input-group input-group-lg">
                                        <span class="input-group-addon">密       码</span>
                                        <input type="text" class="form-control" placeholder="Twitterhandle" name="password">
                                    </div>
                                    <br>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                                        </button>
                                        <button class="submit btn btn-primary">提交</button>
                                    </div>
                                </form>
                            </div>

                        </div><!-- /.modal-content -->
                    </div><!-- /.modal -->
                </div>
            </div>
            <%
                }
            %>
        </div>
    </nav>
    <div class="panel panel-primary" >
        <div class="panel-heading">
            <h3 class="panel-title" style="text-align: center">信息面板</h3>
        </div>
        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover table-condensed">
                    <thead>
                    <tr>
                        <th style="min-width: 120px"><p class="text-center">姓名</p></th>
                        <th style="min-width: 120px"><p class="text-center">部门</p></th>
                        <th style="min-width: 120px"><p class="text-center">电话</p></th>
                        <%
                            if (user.getParam().equals("admin")){
                        %>
                        <th><p class="text-center">操作</p> </th>
                        <%
                            }
                        %>

                    </tr>
                    </thead>
                    <tbody>
                    <%
                        int a = 0;
                        PageInfo pageInfo = (PageInfo)request.getAttribute("msg");
                        List<PersonWithDept> list = pageInfo.getList();
                        for (PersonWithDept person:list){
                            a++;
                    %>
                    <tr style="text-align: center">
                        <td><p class="text-center"><%= person.getPersonname()%></p></td>
                        <td><p class="text-center"><%= person.getDepartmentname()%></p></td>
                        <td><p class="text-center"><%= person.getTel()%></p></td>
                        <%
                            if (user.getParam().equals("admin")){
                        %>
                            <td>
                            <button class="btn btn-primary" data-toggle="modal" data-target="#myModal<%=a%>" style="background-color: #d58512;">编辑</button>
                            <!-- 模态框（Modal） -->
                            <div class="modal fade" id="myModal<%=a%>" tabindex="-1" role="dialog" aria-labelledby="myModalLabe<%=a%>" aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                                &times;
                                            </button>
                                            <h4 class="modal-title" id="myModalLabe<%=a%>">
                                                编辑用户信息
                                            </h4>
                                        </div>
                                        <div style="padding: 100px 100px 10px;">
                                            <form class="bs-example bs-example-form" role="form" action="/person/update" method="post">
                                                <div class="input-group input-group-lg">
                                                    <span class="input-group-addon">姓       名</span>
                                                    <input type="text" class="form-control" value="<%=person.getPersonname()%>" name="name">
                                                </div>
                                                <br>
                                                <div class="input-group input-group-lg">
                                                    <span class="input-group-addon">电       话</span>
                                                    <input type="text" class="form-control" value="<%=person.getTel()%>" name="tel">
                                                </div>
                                                <br>
                                                <div class="input-group input-group-lg">
                                                    <span class="input-group-addon">部       门</span>
                                                    <input type="text" class="form-control" value="<%=person.getDepartmentname()%>" name="department">
                                                </div>
                                                <br>
                                                <div class="input-group input-group-lg">
                                                    <span class="input-group-addon">用户名</span>
                                                    <input type="text" class="form-control" value="<%=person.getLoginname()%>" name="username">
                                                </div>
                                                <br>
                                                <div class="input-group input-group-lg">
                                                    <span class="input-group-addon">密       码</span>
                                                    <input type="text" class="form-control" value="<%=person.getPassword()%>" name="password">
                                                </div>
                                                <br>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                                                    </button>
                                                    <button class="submit btn btn-primary">提交</button>
                                                </div>
                                            </form>
                                        </div>

                                    </div><!-- /.modal-content -->
                                </div><!-- /.modal -->
                            </div>
                            <a href="/person/delet?id=<%=person.getPersonid()%>" class="btn btn-primary" style="background-color: red">删除</a>
                        </td>
                        <%
                            }
                        %>

                    </tr>
                    <%
                        }
                    %>
                    </tbody>
                </table>
        </div>
    </div>

        <nav class="navbar navbar-inverse" role="navigation">
            <div class="container-fluid">
                <div class="navbar-header navbar-brand2">
                    <a class="navbar-brand"  href="#">用户管理</a>
                </div>
                <div class= "back">
                    <a href="/person/get" class="btn btn-primary" style="margin-bottom: 18px">返回用户管理初始页面</a>
                        <ul class="pagination  page" style="float: right">
                            <%
                                if (pageInfo.isIsFirstPage()==false){
                            %>
                            <li><a href="/person/get?pageNum=<%=pageInfo.getPageNum()-1%>" style="mso-hide: all">&laquo;</a></li>
                            <%
                                }
                            %>
                            <%
                                for (int i = 1;i<=pageInfo.getPages();i++){
                            %>
                                <li><a href="/person/get?pageNum=<%=i%>"><%=i%></a></li>
                            <%
                                }
                            %>
                            <%
                                if (pageInfo.isIsLastPage()==false){
                            %>
                            <li><a href="/person/get?pageNum=<%=pageInfo.getNextPage()%>">&raquo;</a></li>
                            <%
                                }
                            %>
                        </ul>
                </div>
            </div>

        </nav>

    </div>
</div>
</body>
</html>
